package pack0923;

import java.util.Scanner;

public class DemoD {

    public static void a() {
        Scanner scan = new Scanner(System.in);
        double[] scores = new double[5];
        double sum = 0;
        // 给数组赋值
        for (int i = 0; i < scores.length; i++) {
            System.out.print("请输入成绩：");
            double score = scan.nextDouble();
            scores[i] = score;
        }
        // 统计数组的和
        int i = 0;
        while (i < scores.length) {
            sum += scores[i];
            i++;
        }
        System.out.println(sum / scores.length);
    }

    public static void b() {
        int[] array = {8, 4, 2, 1, 23, 344, 12};
        int sum = 0;
        boolean flag = false;
        Scanner scan = new Scanner(System.in);
        System.out.print("input:");
        int num = scan.nextInt();
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + ",");
            sum += array[i];
            if (num == array[i]) {
                flag = true;
            }
        }
        System.out.println("\b");
        System.out.println("和是：" + sum);
        System.out.println("是否存在：" + flag);
    }

    public static void c() {
        Scanner scan = new Scanner(System.in);
        int len = (int) (Math.random() * 20 + 10);
        int[] array = new int[len];
        for (int i = 0; i < len; i++) {
            array[i] = (int) (Math.random() * 20 + 1);
        }
        System.out.print("Input:");
        int num = scan.nextInt();
        for (int i = 0; i < len; i++) {
            System.out.print(array[i] + ",");
        }
        System.out.println("\b");
        for (int i = 0; i < len; i++) {
            if (num == array[i]) {
                System.out.println("位置是：" + i);
                break;
            }
        }
    }

    public static void main(String[] args) {
        c();
    }
}